﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/main/main_top.jsp"%>
</head>
<body>
	<div class="container-fluid" id="main-container">
		<div id="breadcrumbs">
			<ul class="breadcrumb">
				<li><i class="icon-home"></i> <a>商户管理</a> <span class="divider">
						<i class="icon-angle-right"></i>
				</span></li>
				<li class="active">活动发布</li>
			</ul>
			<!--.breadcrumb-->
		</div>
		<div id="page-content" class="clearfix">
			<div class="row-fluid">
				<div class="row-fluid">
					<!-- 检索  -->
					<form action="publishActivity/list.do" method="post"
						name="commercialPublishActivityForm"
						id="commercialPublishActivityForm">
						<input type="hidden" name="organid" id="organid"
							value="${pageData.organid }" />
						<table>
							<tr>
								<td><input class="span10 date-picker" id="lastStart"
									name="lastStart" value="${pageData.lastStartShow}" type="text"
									data-date-format="yyyy-mm-dd" readonly="readonly"
									style="width: 100px;" placeholder="到期日期从" /></td>
								<td><input class="span10 date-picker" id="lastEnd"
									name="lastEnd" value="${pageData.lastEndShow}" type="text"
									data-date-format="yyyy-mm-dd" readonly="readonly"
									style="width: 100px;" placeholder="到期日期至" /></td>
								<c:if test="${pageData.org_act_type == '2' }">
								<td style="vertical-align: top;"><select
									class="chzn-select" name="act_check_state"
									data-placeholder="审核状态"
									style="vertical-align: top; width: 100px;">
										<option value=""></option>
										<option value="1"
											<c:if test="${pageData.act_check_state == '1' }">selected</c:if>>未审核</option>
										<option value="2"
											<c:if test="${pageData.act_check_state == '2' }">selected</c:if>>审核通过</option>
										<option value="3"
											<c:if test="${pageData.act_check_state == '3' }">selected</c:if>>已结束</option>
										<option value="4"
											<c:if test="${pageData.act_check_state == '4' }">selected</c:if>>未通过</option>
								</select></td>
								</c:if>
								<td style="vertical-align: top;"><select
									class="chzn-select" name="org_act_type"
									data-placeholder="商户活动类型"
									style="vertical-align: top; width: 150px;">
										<option value=""></option>
										<option value="1"
											<c:if test="${pageData.org_act_type == '1' }">selected</c:if>>普通活动</option>
										<option value="2"
											<c:if test="${pageData.org_act_type == '2' }">selected</c:if>>邀约活动</option>
								</select></td>
								<td style="vertical-align: top;"><a
									class="btn btn-mini btn-light" onclick="searchAct();"
									title="查询"><i id="nav-search-icon" class="icon-search"></i>查询</a></td>
							</tr>
						</table>
						<!-- 检索  -->

						<table id="table_report"
							class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>序号</th>
									<th>活动主题</th>
									<th><i class="icon-time hidden-phone"></i>开始日期</th>
									<th><i class="icon-time hidden-phone"></i>结束日期</th>
									<th>活动类型</th>
									<th>商户活动类型</th>
									<th>成员类型</th>
									<th>报名方式</th>
									<th>活动金额</th>
									<th>参与方式</th>
									<th>人数</th>
									<th>状态</th>
									<th>图片</th>
									<th class="center">操作</th>
								</tr>
							</thead>

							<tbody>
								<!-- 开始循环 -->
								<c:choose>
									<c:when test="${not empty varList}">
										<c:forEach items="${varList}" var="var" varStatus="vs">
											<tr>
												<td class='center' style="width: 30px;">${vs.index+1}</td>
												<td>${fn:substring(var.info_title ,0,50)}...</td>
												<td>${var.act_pub_time }</td>
												<td>${var.act_end_time }</td>
												<td><c:if test="${var.org_act_type == 2}">${var.act_type_name }</c:if></td>
												<td><c:if test="${var.org_act_type == 1}">
										普通活动
									</c:if> <c:if test="${var.org_act_type == 2}">
										邀约活动
									</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">
														<c:if test="${var.member_type == 1}">
										男生
										</c:if>
														<c:if test="${var.member_type == 2}">
										女生
										</c:if>
														<c:if test="${var.member_type == 3}">
										不限
										</c:if>
													</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">
														<c:if test="${var.enroll_method == 1}">
										全额预付
										</c:if>
														<c:if test="${var.enroll_method == 2}">
										预付定金
										</c:if>
														<c:if test="${var.enroll_method == 3}">
										免费
										</c:if>
													</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">${var.act_amount }</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">
														<c:if test="${var.join_method == 2}">
										凭报名手机号参加
										</c:if>
													</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">${var.person_limite }</c:if></td>
												<td><c:if test="${var.org_act_type == 2}">
														<c:if test="${var.act_check_state == '1' }">
															<span class="label label-important arrowed-in">未审核</span>
														</c:if>
														<c:if test="${var.act_check_state == '2' }">
															<span class="label label-success arrowed">审核通过</span>
														</c:if>
														<c:if test="${var.act_check_state == '3' }">
															<span class="label label-success arrowed">已结束</span>
														</c:if>
														<c:if test="${var.act_check_state == '4' }">
															<span class="label label-success arrowed">未通过</span>
														</c:if>
													</c:if></td>
												<td><c:if
														test="${var.act_img != '' && var.act_img != null }">
														<a href="<%=basePath%>${var.act_img}" target="_blank"><img
															src="<%=basePath%>${var.act_img}" width="50" /></a>
													</c:if></td>
												<td style="width: 60px;" class="center">
													<div class='hidden-phone visible-desktop btn-group'>
														<a class='btn btn-mini btn-info' title="编辑"
															onclick="edit('${var.id }','${var.org_act_type }');"><i class='icon-edit'></i></a>
														<a class='btn btn-mini btn-danger' title="删除"
															onclick="del('${var.id }','${var.org_act_type }');"><i class='icon-trash'></i></a>
													</div>
												</td>
											</tr>
										</c:forEach>

										<!-- <tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr> -->
									</c:when>
									<c:otherwise>
										<tr class="main_info">
											<td colspan="11" class="center">没有相关数据</td>
										</tr>
									</c:otherwise>
								</c:choose>
							</tbody>
						</table>

						<div class="page-header position-relative">
							<table style="width: 100%;">
								<tr>
									<td style="vertical-align: top;"><a
										class="btn btn-small btn-success"
										onclick="add(${pageData.organid });">新增</a></td>
									<td style="vertical-align: top;"><div class="pagination"
											style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}</div></td>
								</tr>
							</table>
						</div>
					</form>
				</div>
				<!-- PAGE CONTENT ENDS HERE -->
			</div>
			<!--/row-->

		</div>
		<!--/#page-content-->
	</div>
	<!--/.fluid-container#main-container-->
	<!-- 返回顶部  -->
	<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i
		class="icon-double-angle-up icon-only"></i>
	</a>

	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
	<script type="text/javascript" src="static/js/ace.min.js"></script>
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
	<!-- 单选框 -->
	<script type="text/javascript"
		src="static/js/bootstrap-datepicker.min.js"></script>
	<!-- 日期框 -->
	<script type="text/javascript" src="static/js/bootbox.min.js"></script>
	<!-- 确认窗口 -->
	<!-- 引入 -->

	<script type="text/javascript">
		$(top.hangge());
		
		//检索
		function searchAct(){
			var start = $("#lastStart").val();  
		    var end = $("#lastEnd").val();  
		    if(start != null && end != null){
		        if(end < start){  
		            alert('结束时间不能早于开始时间！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		          
		        var days = daysBetween(start,end);  
		        if(days>30){  
		            alert('时间跨度不能超过一个月！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		    }  
		    
			$("#commercialPublishActivityForm").submit();
		}
		
		//+--------------------------------------------------    
		//| 求两个时间的天数差 日期格式为 YYYY-MM-dd     
		//+--------------------------------------------------  
		function daysBetween(DateOne,DateTwo)    
		{     
		    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));    
		    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);    
		    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));    
		    
		    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));    
		    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);    
		    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));    
		    
		    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);     
		    return Math.abs(cha);    
		}  
		
		//新增
		function add(organid){
			top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>publishActivity/goAddPublishActivity.do?organid='+organid;
			 diag.Width = 800;
			 diag.Height = 650;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location.reload()",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//修改
		function edit(activity_id,org_act_type){
			top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>publishActivity/goEditPublishActivity.do?activity_id='+activity_id+'&org_act_type='+org_act_type;
			 diag.Width = 800;
			 diag.Height = 650;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location.reload()",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//删除
		function del(activity_id,org_act_type){
			bootbox.confirm("确定要删除该记录?", function(result) {
				if(result) {
					var url = "<%=basePath%>publishActivity/deletePublishActivity.do?activity_id="+activity_id+"&org_act_type="+org_act_type;
					$.get(url,function(data){
						//if(data=="success"){
							nextPage(${page.currentPage});
						//}
					});
				}
			});
		}
		</script>
	<script type="text/javascript">
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			//日期框
			$('.date-picker').datepicker();
		});
		</script>
</body>
</html>

